﻿Imports System.Reflection
Imports System.Resources
Imports System.IO
Imports System.ComponentModel
Imports System.Drawing
Imports ajayumi.develop.win32.Monster.Base

Public Class DrawHeartShaped
    Inherits ActionBase

    Private m_ActionType As ActionType
    ''' <summary>
    ''' 动作类型
    ''' </summary>
    Public Property [ActionType]() As ActionType
        Get
            Return m_ActionType
        End Get
        Set(ByVal value As ActionType)
            m_ActionType = value
        End Set
    End Property

    Public Sub New()
        MyBase.New(My.Settings.ResName)
        Me.m_ResourceManager = New System.Resources.ResourceManager( _
            String.Concat(My.Settings.ResName, ".DrawHeartShapedAction"), m_Assembly)

        Me.Name = ActionType.DrawHeartShaped.ToString()
        Me.LowIndex = 6
        Me.UpperIndex = 37
        Me.Total = 32
        Me.ActionType = ActionType.DrawHeartShaped
        Me.Duration = Me.Total * TIMER_INTERVAL * 2
    End Sub

    Public Overrides Sub Init()
        'Try
        '    Me.m_Assembly = Reflection.Assembly.Load(My.Settings.ResName)
        '    Me.m_ResourceManager = New System.Resources.ResourceManager(String.Concat(My.Settings.ResName, ".DrawHeartShapedAction"), Me.m_Assembly)
        '    For i As Integer = Me.LowIndex To Me.UpperIndex
        '        Dim _Name As String = String.Format("zmg_{0}", i)
        '        Dim _Image As Image = DirectCast(Me.m_ResourceManager.GetObject(_Name), Image)
        '        Me.Add(New ImageInfo() With {.Name = _Name})

        '        Dim _ProgressPercentage As Integer = CInt(CSng(i - Me.LowIndex) / CSng(Total) * 100.0!)
        '        Me.OnResourcesProgressChanged(New ProgressChangedEventArgs(_ProgressPercentage, Me))
        '    Next

        '    Me.OnResourcesCompleted(New AsyncCompletedEventArgs(Nothing, False, Me))
        'Catch ex As Exception
        '    Me.OnResourcesCompleted(New AsyncCompletedEventArgs(ex, False, Me))
        'End Try
    End Sub

    Public Overrides Sub Init(ByVal state As Object)
        Dim _BackgroundWorker As BackgroundWorker = DirectCast(state, BackgroundWorker)
        Try
            '取资源文件中的图片
            For i As Integer = Me.LowIndex To Me.UpperIndex
                Dim _Name As String = String.Format("zmg_{0}", i)
                Dim _ImageInfo As New ImageInfo() With {.Name = _Name}
                Me.Add(_ImageInfo)

                'Threading.Thread.Sleep(50)
                Dim _ProgressPercentage As Integer = CInt(CSng(i - Me.LowIndex + 1) / CSng(Total) * 100.0!)
                _BackgroundWorker.ReportProgress(_ProgressPercentage, _ImageInfo)
            Next
        Catch ex As Exception
            _BackgroundWorker.CancelAsync()
        End Try
    End Sub

    Public Overrides Function ToString() As String
        Return "绘制心形状动作"
    End Function
End Class
